import { _decorator, Component, Node } from 'cc';
import { EventListener } from '../../core/EventListener';
import { GameDefine } from '../../game/GameDefine';
import { Constants } from '../../game/Constants';
const { ccclass, property } = _decorator;

@ccclass('RoleItem')
export class RoleItem extends Component {
    @property() unLockLv: number = 1;
    @property(Node) icon: Node = null;
    @property(Node) lock: Node = null;

    start() {
        EventListener.on(Constants.update_fortress_level, this.initUI, this);
    }

    protected onEnable(): void {
        this.initUI();
    }

    private initUI() {
        if (GameDefine.FortressLevel >= this.unLockLv) {
            this.icon.active = true;
            this.lock.active = false;
        } else {
            this.icon.active = false;
            this.lock.active = true;
        }
    }
}